from django.db import models


# Create your models here.
class FirstMenu(models.Model):
    id = models.AutoField(primary_key=True)
    auth_name = models.CharField(max_length=20, verbose_name="一级菜单名称")
    path = models.CharField(max_length=20, verbose_name="路径", null=True, blank=True)
    order = models.IntegerField(verbose_name="排序", default=0)

    class Meta:
        verbose_name = "一级菜单"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.auth_name


class SecondMenu(models.Model):
    id = models.AutoField(primary_key=True)
    first = models.ForeignKey(FirstMenu, on_delete=models.CASCADE, verbose_name="一级菜单")
    auth_name = models.CharField(max_length=20, verbose_name="二级菜单名称")
    path = models.CharField(max_length=20, verbose_name="路径")
    order = models.IntegerField(verbose_name="排序", default=0)

    class Meta:
        verbose_name = "二级菜单"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.auth_name
